#include "MainWindow.h"
#include "Config.h"

#include <QThread>

MainWindow::MainWindow(QWidget *parent) : QGraphicsView(parent)
{
    scene = new QGraphicsScene(this);
    setStyleSheet("padding: 0px; border: 0px;");
    setScene(scene);
    setWindowTitle("window");
    setFixedSize(800, 600);
}

void MainWindow::UpdateView(const uint8_t* source)
{
    scene->clear();
    pixmap = QPixmap::fromImage(QImage(source, Config::width(), Config::height(), Config::width() * 3, QImage::Format_RGB888));
    scene->addPixmap(pixmap);
}

void MainWindow::closeEvent(QCloseEvent *event)
{
    emit CloseSignal();
    QThread::msleep(50);
    QWidget::closeEvent(event);
}
